package redis

import (
	"context"
	"github.com/redis/go-redis/v9"
	"time"
)

var redisClient *redis.Client

func init() {
	redisClient = redis.NewClient(&redis.Options{
		Addr:     "localhost:6379",
		Password: "123456", // 没有密码，默认值
		DB:       0,        // 默认DB 0
	})
}

func Redisget(key string) string {
	ctx := context.Background()
	var result = redisClient.Get(ctx, key)
	return result.Val()
}
func Redisset(key string, value interface{}) {
	ctx := context.Background()
	redisClient.Set(ctx, key, value, 24*time.Hour)
}
